package com.hengxinguotong.hxgtwygsp.ui.regulation.propertyRule;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.hengxinguotong.hxgtwygsp.R;
import com.hengxinguotong.hxgtwygsp.model.Rule;
import com.hengxinguotong.hxgtwygsp.ui.base.BaseTabFragment;
import com.hengxinguotong.hxgtwygsp.ui.readFile.FileDisplayActivity;
import com.hengxinguotong.hxgtwygsp.ui.regulation.NoticeAndRuleData;
import com.hengxinguotong.hxgtwygsp.ui.regulation.RuleAdapter;
import com.hengxinguotong.hxgtwygsp.utils.CommUtil;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 重要通知
 * Created by CS-Yong
 * 2019/8/9  14:18
 */
public class PropertyRuleFragment extends BaseTabFragment {
    @BindView(R.id.rule_recycler)
    RecyclerView mRuleRecycler;

    private RuleAdapter mAdapter;
    private List<Rule> mList = new ArrayList<>();

    public PropertyRuleFragment() {
    }

    @Override
    public int getLayoutResId() {
        return R.layout.fragment_rule;
    }

    @Override
    public void init() {

        mList = NoticeAndRuleData.getImportantAllList();

        mAdapter = new RuleAdapter(R.layout.item_rule,mList);
        LinearLayoutManager manager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
        mRuleRecycler.setLayoutManager(manager);
        mRuleRecycler.setAdapter(mAdapter);

        mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                Rule rule = mList.get(position);
                FileDisplayActivity.show(getContext(), rule.getTitle(), CommUtil.getDataDir(getContext()) + File.separator +rule.getFileName());
            }
        });
    }

    private void mockView() {
        mList.add(new Rule("业主大会议事规则","2019-03-26","2_1.docx"));
        mList.add(new Rule("中华人民共和国2019年业主委员会章程","2019-02-23","2_1.docx"));
        mList.add(new Rule("业主委员会工作规则业主委员会工作规则业主委员会工作规则","2019-01-14","2_1.docx"));
        mList.add(new Rule("湖北省武汉市武昌区2018年度业委会会议制度","2019-01-11","2_1.docx"));
        mList.add(new Rule("维修基金使用审核制度","2018-11-23","2_1.docx"));
        mList.add(new Rule("征求业主意见制度征求业主意见制度征求业主意见制度","2018-11-21","2_1.docx"));
        mList.add(new Rule("维修基金使用审核制度","2018-10-20","2_1.docx"));
        mList.add(new Rule("业委会活动经费开支管理制度","2018-09-23","2_1.docx"));
    }


}
